//
//  AppDelegate.swift
//  SinaWeiBo
//
//  Created by 谭淇 on 15/3/4.
//  Copyright (c) 2015年 谭淇. All rights reserved.
//

import UIKit
import SimpleNetwork

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        
        // 检测沙盒中是否已经保存了token
        if let token = AccessToken.loadAccessToken() {
            // 显示主界面
//            showMainInterface()
        } else {
            // 添加通知监听
            let sb = UIStoryboard(name: "OAuth", bundle: nil)
            window!.rootViewController = (sb.instantiateInitialViewController() as! UIViewController)
        }
        return true
    }
    
/// 显示主界面
    func showMainInterface() {
        let sb = UIStoryboard(name: "Main", bundle: nil)
        window!.rootViewController = (sb.instantiateInitialViewController() as! MainNavigationController)
        
        // 设置nav按钮外观
        setNavAppearance()
    }
    
/// 设置nav按钮外观
    func setNavAppearance() {
        // 统一设置UIBarButtonItem的外观
        UIBarButtonItem.appearance().tintColor = UIColor.orangeColor()
    }
}

